package xyz.lwm.lazycat.beans;

import xyz.lwm.lazycat.setting.Setting;
import xyz.lwm.lazycat.setting.SettingSetter;

/**
 * <h3>自定义设置, 在 bean 实例化之前</h3>
 * <p>在 {@link Setting} 加载后, 同时在 bean 使用前处理, 常用于替换配置. </p>
 * <p>比如: 数据库用户和密码的密文解密</p>
 * <pre>{@code
 * @Bean
 * public class MySettingCustomizer implements SettingCustomizer {
 *     @Override
 *     public void customize(Setting setting, SettingSetter settingSetter) {
 *         settingSetter.set("db.password", AESUtil.decrypt(setting.get("db.password")));
 *     }
 * }
 * }</pre>
 *
 * @author lwm
 */
@FunctionalInterface
public interface SettingCustomizer extends Functional {

    /**
     * 自定义设置参数
     *
     * @param setting 设置
     * @param settingSetter 修改设置
     */
    void customize(Setting setting, SettingSetter settingSetter);

}
